// 柯里化案例
const _ = require('lodash');

//ES5
// const match = _.curry(function (reg, str) {
//     return str.match(reg);
// })

// ES6
const match = _.curry((reg, str) => str.match(reg));

const haveSpace = match(/\s+/g);
const haveNumber = match(/\d+/g);

//ES5
// const filter = _.curry(function (fn, array) {
//     return array.filter(fn)
// })

// ES6
const filter = _.curry((fn, array) => array.filter(fn));

const findSpace = filter(haveSpace);

// console.log(haveSpace('hello world'));
// console.log(haveNumber('hello world'));



console.log(filter(haveSpace, ['John Connor', 'John_Donne']));

console.log(findSpace(['John Connor', 'John_Donne']));